<?php

namespace maotool\orm\mapper;

use maotool\core\Container;
use maotool\file\DirUtil;
use maotool\object\ReflectionUtil;

class MapperUtil
{

    /**
     * @return void
     */
    public static function scan($path)
    {
        $log_time_start = microtime(true);
        $list = DirUtil::scanFiles($path);
        \maotool\log\Console::debug('Mapper Path 扫描 ' . $path . ' 加载用时：' . number_format(microtime(true) - $log_time_start, 10) . ' 秒。');
        foreach ($list as $item) {
            $object = MapperLoader::object($item["path"]);
            Container::set(["concrete" => $object, "init" => false]);
        }
    }

    public static function get($name)
    {
        return Container::get($name);
    }

}